/*
 * @Author: EyeSklear 1814580085@qq.com
 * @Date: 2024-01-12 19:58:15
 * @LastEditors: EyeSklear 1814580085@qq.com
 * @LastEditTime: 2024-04-15 10:45:07
 * @FilePath: \Scene_Back\src\geojson\geojson.controller.ts
 * @Description:
 *
 * Copyright (c) 2024 by EyeSklear , All Rights Reserved.
 */
import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
} from '@nestjs/common';
import { GeojsonService } from './geojson.service';
import { CreateGeojsonDto } from './dto/create-geojson.dto';
import { UpdateGeojsonDto } from './dto/update-geojson.dto';

import { Request } from 'express';

@Controller('geojson')
export class GeojsonController {
  constructor(private readonly geojsonService: GeojsonService) {}

  @Post('createGeoJsonItem')
  createGeoJsonItem(
    @Body() createGeojsonDto: CreateGeojsonDto,
    @Req() request: Request,
  ) {
    const user = request.user;
    createGeojsonDto.creator = (user as any).email;
    return this.geojsonService.createItem(createGeojsonDto);
  }

  @Get('findAll')
  findAll() {
    return this.geojsonService.findAll();
  }

  @Get('findGeoJsonById/:id')
  findGeoJsonById(@Param('id') id: string) {
    return this.geojsonService.findOne(id);
  }

  @Patch('updateGeoJsonItem/:id')
  updateGeoJsonItem(
    @Param('id') id: string,
    @Body() updateGeojsonDto: UpdateGeojsonDto,
  ) {
    return this.geojsonService.update(id, updateGeojsonDto);
  }

  @Delete('removeGeoJsonItem/:id')
  removeGeoJsonItem(@Param('id') id: string) {
    return this.geojsonService.remove(id);
  }
}
